// 封装医院设置相关请求的函数
import { Key } from 'react'
import { request } from '@utils/http'
import {
  IhospitalSetRes,
  IAddParams,
  IhospitalSet,
} from './model/hospitalSetTypes'
export function reqGetHospitalSets(
  page: number,
  limit: number,
  hosname?: string,
  hoscode?: string
) {
  // 注意： 如果请求url写的是相对路径，则axios会自动将当前发送请求的html页面的url地址拼接在前面
  return request.get<any, IhospitalSetRes>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: {
        hosname: hosname,
        hoscode: hoscode,
      },
    }
  )
}

export function reqAddHospitalSet(data: IAddParams) {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, data)
}

export function reqGetHospitalSet(id: string) {
  return request.get<any, IhospitalSet>(`/admin/hosp/hospitalSet/get/${id}`)
}

export function reqUpdateHospitalSet(data: IAddParams) {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, data)
}

export function reqDelHospitalSet(id: string) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

export function reqBatchDelHospitalSets(ids: Key[]) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids,
  })
}
